package com.anandsoftware.negotiator.server;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class ServerContext {

	public static String SERVER_MODE;
	public static int PORT;
	public ServerContext(String configPath) throws FileNotFoundException, IOException, ServerContextInitializationFailed {
		Properties prop = new Properties();
		prop.load(new FileInputStream(configPath));
		
		SERVER_MODE = prop.getProperty("SERVER.MODE");
		if(SERVER_MODE == null){
			throw new ServerContextInitializationFailed("Error In key : SERVER.MODE");
		}
		
		PORT = Integer.parseInt(prop.getProperty("SERVER.PORT"));
		if(PORT < 1000){
			throw new ServerContextInitializationFailed("Error In key : SERVER.PORT Must be > 1000");
		}
	}
}
